Skip to content

Introduce Sphinx doctest builds#1406

Open
sirosen wants to merge 7 commits into
globus:mainfrom
sirosen:doctest
Open

Introduce Sphinx doctest builds#1406
sirosen wants to merge 7 commits into
globus:mainfrom
sirosen:doctest

Conversation

@sirosen

@sirosen sirosen commented Jul 2, 2026

Copy link
Copy Markdown
Member

In order to allow for doctest usage, but without mandating it everywhere that examples are written (today and into the future), add Sphinx config which allows for use of the doctest directive but does not automatically run all examples as doctests.
A pass over existing examples found a few items worth trying to turn into doctests, but this effort may not have been perfectly complete.

  • Setup sphinx doctest
  • Convert Timers data module docstrings to doctest
  • Add TimersClient to doctest and refine config
  • Convert GCS ConnectorTable to doctests
  • Convert scope documentation to doctests
  • Doctest part of the relative deadline doc
  • Add changelog for introduction of doctest

sirosen added 7 commits July 1, 2026 16:58
- enable the plugin
- disable default console block behavior
- new tox env
- new CI config
Improve our doctest config with
- a wrapped version of `mock.patch` which does auto-rollback
- pre-set imports for all doctests
Comment thread docs/conf.py
extensions = [
# sphinx-included extensions
"sphinx.ext.autodoc",
"sphinx.ext.doctest",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about how maintainers discover what different sphinx directives mean in this repository as we expand the number of internally-maintained & dependency extensions.

With the context of reviewing this PR which adds the sphinx.ext.doctest extension in a separate file, I was eventually able to find documentation for what testsetup:: doctest::, and testcode:: meant as symbols. If I encountered those in the context of browsing through a file though, I don't think I would've been able to backtrace why those symbols are meaningful (maybe with the exception of doctest because the extension happens to be named the same).

I think it's time that we have some in-repository documentation (a DOCUMENTATION.md or similar) that provides a central reference for which directives we're importing, which we've specialized, which we've built ourselves, etc. linking out to relevant docs like https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this comment: that information belongs in our contribution docs. I do not think we should block this addition on these grounds, in a case of "the perfect is the enemy of the good".

Can we describe the follow-up we would like in the form of an issue or story? (I think in-repo issue tracking would be appropriate in this case.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to find doctest trivially with a search for "python sphinx testcode". I think we need to discuss what level of detail is needed in our contributor documentation. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants